package org.i0o.appliancemanager.ui.dialog;

import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.i0o.appliancemanager.ui.helper.UITools;

public class CreateCardDialog extends BaseDialog {
	// 默认缝隙大小
	private static final int	CONTAINERSIZE	= 5;
	private JTextField			txtCardNum;
	private JButton	btnCreateCard;
	private JButton	btnCancel;
	private JButton	btnHelp;

	public CreateCardDialog(Frame owner, boolean modal) {
		super(owner, modal);
	}

	/**
	 * 
	 */
	private static final long	serialVersionUID	= -4943719284691063806L;

	@Override
	protected void initLayout() {
		JPanel backgroundPanel = UITools.createPanel();
		this.add(backgroundPanel);

		GroupLayout layout = new GroupLayout(backgroundPanel);
		backgroundPanel.setLayout(layout);

		GridLayout carNumLayout = new GridLayout(1, 2);
		JPanel cardNumPanel = UITools.createPanel(new FlowLayout());
		cardNumPanel.setBorder(BorderFactory.createEtchedBorder());

		JLabel lblCardNum = UITools.createLabel("卡号", cardNumPanel);
		this.txtCardNum = UITools.createSingleText("", cardNumPanel);

		// 内容
		JPanel contentPanel = UITools.createPanel();
		contentPanel.setBorder(BorderFactory.createEtchedBorder());
		
		//按钮
		this.btnCreateCard = UITools.createButton("发卡");
		this.btnCancel = UITools.createButton("取消");
		this.btnHelp = UITools.createButton("帮助");

		layout.setHorizontalGroup(layout
				.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(layout
						.createSequentialGroup()
						.addGap(CONTAINERSIZE)
						.addGroup(layout
								.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
								.addComponent(cardNumPanel,
										GroupLayout.DEFAULT_SIZE,
										GroupLayout.DEFAULT_SIZE,
										Short.MAX_VALUE)

								.addComponent(contentPanel,
										GroupLayout.DEFAULT_SIZE,
										GroupLayout.DEFAULT_SIZE,
										Short.MAX_VALUE))

						.addGap(CONTAINERSIZE)));

		layout.setVerticalGroup(layout
				.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(layout
						.createSequentialGroup()
						.addGap(CONTAINERSIZE)
						.addGroup(layout
								.createSequentialGroup()
								.addComponent(cardNumPanel,
										GroupLayout.PREFERRED_SIZE,
										40,
										GroupLayout.PREFERRED_SIZE)
								.addGap(CONTAINERSIZE)
								.addComponent(contentPanel)
								.addGap(CONTAINERSIZE)

						).addGap(CONTAINERSIZE)));

	}

	@Override
	protected void initListener() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void initStyle() {
		this.setTitle("发型新卡");
		this.setSize(400, 600);
	}

}
